Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mutating webhook for defaulting storageclass params #3055

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

leelavg
Copy link
Contributor

@leelavg leelavg commented Feb 24, 2025

webhook for populating secret names and clusterid in storageclass parameters for supported provisioners based on local storageconsumer.

Copy link
Contributor

openshift-ci bot commented Feb 24, 2025

Skipping CI for Draft Pull Request.
If you want CI signal for your change, please convert it to an actual PR.
You can still manually trigger a test run with /test all

@openshift-ci openshift-ci bot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Feb 24, 2025
Copy link
Contributor

openshift-ci bot commented Feb 24, 2025

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: leelavg
Once this PR has been reviewed and has the lgtm label, please assign nb-ohad for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@leelavg leelavg force-pushed the sc-hook branch 3 times, most recently from 892e7b9 to a83feba Compare February 27, 2025 05:42
@leelavg leelavg marked this pull request as ready for review February 27, 2025 07:08
@openshift-ci openshift-ci bot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Feb 27, 2025
@leelavg
Copy link
Contributor Author

leelavg commented Feb 27, 2025

For external storageclasses the assumption was it already has details filled and webhook simply don't mutate any of them.

Expression: fmt.Sprintf(
"request.object.provisioner in ['%s', '%s']",
util.RbdDriverName,
util.CephFSDriverName,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nfs need to be added here?

Copy link
Contributor Author

@leelavg leelavg Feb 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

a separate PR should follow for NFS, I can't send PR for something I didn't try out.

Operations: []admrv1.OperationType{admrv1.Create},
},
},
FailurePolicy: ptr.To(admrv1.Fail),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wont having FailurePolicy will have sideeffect on other classes if the webhook server is down? can you please check on confirm on it?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it'll but while setting webhook I'm using match conditions on our provisioners only, if you are referring non-odf sc as other they are exempted.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what will be the impact on the SC for external mode?

Comment on lines +33 to +50
var webhookService = corev1.Service{
Spec: corev1.ServiceSpec{
Ports: []corev1.ServicePort{
{
Name: "ocs-operator-webhook",
Port: webhookServicePort,
Protocol: corev1.ProtocolTCP,
TargetPort: intstr.FromInt32(WebhookServiceTargetPort),
},
},
Selector: map[string]string{
"name": "ocs-operator",
},
Type: corev1.ServiceTypeClusterIP,
},
}

var storageClassMutatingWebhook = admrv1.MutatingWebhook{
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we need service and webhook created as part of the code not part of yaml files in the CSV? can you please specify the reason and pros and cons?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

svc:
I want to ensure the annotation even if it's removed by mistake and having the svc in bundle doesn't ensure it

webhook:
I need support for setting MatchConditions which aren't exposed on CSV, need typed structs + enforcement and so not part of bundle


var supportedProvisioners = []string{
util.RbdDriverName,
util.CephFSDriverName,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nfs is missing if its enabled.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

a separate PR should follow for NFS, I can't send PR for something I didn't try out.

clusterID := ""
for idx := range storageConsumerList.Items {
consumer := &storageConsumerList.Items[idx]
if consumer.Annotations[defaults.StorageConsumerTypeAnnotation] == defaults.StorageConsumerTypeLocal {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what happens if i create a storageconsumer and add local annotation. no one will block me from doing that isnt it?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, either this or an immutable field in the spec, we went w/ the annotation as not to backport spec changes.

let's discuss in upcoming meetings if any change is required.

if storageClass.Parameters["csi.storage.k8s.io/provisioner-secret-name"] != "" {
patches = append(patches, jsonpatch.JsonPatchOperation{
Operation: "add",
Path: "/parameters/csi.storage.k8s.io~1provisioner-secret-name",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

csi.storage.k8s.io~1provisioner-secret-name typo in this one

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i felt it as typo, can you please add a comment for this one :(

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done.

Copy link
Contributor

openshift-ci bot commented Mar 3, 2025

@leelavg: The following test failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
ci/prow/ocs-operator-bundle-e2e-aws 7c8e574 link true /test ocs-operator-bundle-e2e-aws

Full PR test history. Your PR dashboard.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here.

@leelavg
Copy link
Contributor Author

leelavg commented Mar 5, 2025

/hold

Will squash after final review

@openshift-ci openshift-ci bot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Mar 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants